{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}
<div class="p-3">
	<div class="gg-form-bar border-t border-x">
		<form id="taskForm" class="layui-form" lay-filter="barsearchform">
			<div class="layui-input-inline" style="">
				<!-- <select name="status" lay-filter="status">
					<option value="">领域</option>
					<option value="1">未开始</option>
					<option value="2">进行中</option>
					<option value="3">已完成</option>
					<option value="4">已关闭</option>
				</select> -->
				<!-- <select name="industry_id" lay-filter="industry_id">
					<option value="">请选择分类</option>
					{notempty name="$note"}
						{volist name="$industry" id="v"}
						<option value="{$v.id}" {eq name="$note.industry_id" value="$v.id" }selected{/eq}>{$v.title}</option>
						{/volist}
					{else/}
						{volist name="$industry" id="v"}
						<option value="{$v.id}">{$v.title}</option>
						{/volist}
					{/notempty}
				</select> -->
			</div>
			
			<div class="layui-input-inline" style="width:200px;">
				<input type="text" name="keywords" placeholder="内容" class="layui-input" autocomplete="off" />
			</div>
			<div class="layui-input-inline" style="width:150px;">
				<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform"><i class="layui-icon layui-icon-search mr-1"></i>搜索</button>
				<!-- <button type="reset" class="layui-btn layui-btn-reset" lay-filter="reset">清空</button> -->
			</div>
		</form>
	</div>
	
</div>
<div class="p-3">
	<table class="layui-hide" id="test" lay-filter="test"></table>
	
	
</div>

<script type="text/html" id="status">
	<!-- <i class="layui-icon {{#  if(d.status == 1){ }}green layui-icon-ok{{#  } else { }}yellow layui-icon-close{{#  } }}"></i> -->



</script>
<!-- <script type="text/html" id="toolbarDemo">
  <div class="layui-btn-container">
    <span class="layui-btn layui-btn-sm" lay-event="add">+ 添加</span>

  </div>
  
</script> -->
<script type="text/html" id="barDemo">
<div class="layui-btn-group">
	<!-- <input type="checkbox" name="zzz" lay-skin="switch"  lay-filter="switchTest" lay-event="tongguo" lay-text="通过|驳回"> -->
	<span class="layui-btn layui-btn-normal layui-btn-xs" lay-event="recover">回复</span>
	
		
	
	<span class="layui-btn layui-btn-xs" lay-event="edit">编辑</span>
	<span class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</span>
</div>
</script>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
	const moduleInit = ['tool'];
	function gouguInit() {
		var table = layui.table, tool = layui.tool ,form = layui.form;	
		layui.pageTable = table.render({
			elem: '#test',
			title: '平台互动列表',
			toolbar: '#toolbarDemo',
			defaultToolbar: false,
			page: true, //开启分页
			limit: 20,
			url: "/note/index/interaction", //数据接口		
			cols: [
				[
					{
						field: 'id',
						title: 'ID号',
						align: 'center',
						width: 80
					}, {
						field: 'content',
						title: '内容',
						minWidth:240,
						templet: '<div><a data-href="/note/index/interaction_add/diagnosis_id/{{d.id}}.html" class="side-a">{{d.content}}</a></div>'
					}/*, {
						field: 'cate_title',
						title: '展示期间',
						align: 'center',
						width: 196,
						templet: function (d) {
							var html = d.start_time + ' ~ ' + d.end_time;
							return html;
						}
					}*/,{
						field: 'admin',
						title: '提问人',
						align: 'center',
						width: 60
					},{
						field: 'recover',
						title: '回复数',
						align: 'center',
						width: 60
					},{
						field: 'status',
						title: '状态',
						align: 'center',
						width: 60,
						templet: function (d) {

							//var html='';
							if(d.status==1){
								html='<i style="">待处理</i>';
								//html='待处理';
							}else if(d.status==2){
								html='<i style="color:green">已通过</i>';
							}else{
								html='<i style="color:red">已驳回</i>';
							}
							//var html = d.start_time + ' ~ ' + d.end_time;
							return html;
						}
					}/*, 
					{
						field: 'status',
						title: '审核',
						width: 80,
						templet: function (d) {
							if(d.status==1){
								var html = '<input type="checkbox" name="zzz" lay-skin="switch"  lay-filter="switchTest" lay-event="tongguo" lay-text="通过|驳回" checked="checked">';
							}else{
								var html = '<input type="checkbox" name="zzz" lay-skin="switch"  lay-filter="switchTest" lay-event="tongguo" lay-text="通过|驳回">'
							}
							
							return html;
						}
					}*/,{
						field: 'right',
						title: '操作',
						toolbar: '#barDemo',
						width: 130,
						align: 'center'
					}
				]
			]
		});

		//表头工具栏事件
		table.on('toolbar(test)', function(obj){
			if (obj.event === 'add') {
				tool.side("/note/expert/add");
				return;
			}
		})
		//监听搜索提交
		form.on('submit(webform)', function (data) {
			layui.pageTable.reload({ where: data.field });
			return false;
		});
		form.on('switch(switchTest)', function(data){
	    layer.msg('开关 checked：'+ (this.checked ? 'true' : 'false'), {
	      offset: '6px'
	    });
	    layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是 ON|OFF', data.othis)
	  });
		//监听行工具事件
		table.on('tool(test)', function(obj) {
			var data = obj.data;
			if (obj.event === 'edit') {
				tool.side("/note/index/interaction_edit?id="+data.id);
				return;
			}
			if (obj.event === 'recover') {
				tool.side("/note/index/interaction_add?diagnosis_id="+data.id);
				return;
			}
			if (obj.event === 'tongguo') {
				alert('111');
				//tool.side("/note/index/interaction_add?diagnosis_id="+data.id);
				layer.msg('开关 checked：'+ (this.checked ? 'true' : 'false'), {
      offset: '6px'
    });
				return;
			}
			if (obj.event === 'del') {
				layer.confirm('确定删除该留言吗？', {
					icon: 3,
					title: '提示'
				}, function(index) {
					let callback = function (e) {
						layer.msg(e.msg);
						if (e.code == 0) {
							obj.del();
						}
					}
					tool.delete("/note/index/interaction_delete", {id: data.id}, callback);
					layer.close(index);
				});
			}
		});
	}
</script>
{/block}
<!-- /脚本 -->
